package com.xframe.xdal.core.model.mapping;


import com.xframe.xdal.core.annotation.XBelongsTo;
import lombok.Data;

/**
 * 定义了一个引用外键的关系 一对多
 *
 * @author xufeng
 * @version 1.0
 * @date 2022-09-19
 */
@Data
public class BelongsToMapping extends BaseRelation {



    public static BelongsToMapping valueOf(XBelongsTo xBelongsTo){
        BelongsToMapping belongsToMapping = new BelongsToMapping();
        belongsToMapping.foreignKey = xBelongsTo.foreignKey();
        belongsToMapping.targetKey = xBelongsTo.targetKey();
        belongsToMapping.refTableAddString = xBelongsTo.refTableAddString();
        belongsToMapping.as = xBelongsTo.as();
        belongsToMapping.typeName = xBelongsTo.typeName();
        belongsToMapping.refName = xBelongsTo.refName();
        return belongsToMapping;
    }


    public static BelongsToMapping valueOf(String foreignKey,String targetKey,String as,String typeName,String refTableAddString){
        BelongsToMapping belongsToMapping = new BelongsToMapping();
        belongsToMapping.foreignKey = foreignKey;
        belongsToMapping.targetKey = targetKey;
        belongsToMapping.refTableAddString = refTableAddString;
        belongsToMapping.as = as;
        belongsToMapping.typeName = typeName;
        belongsToMapping.refName = "";
        return belongsToMapping;
    }

    public static BelongsToMapping valueOf(String foreignKey,String targetKey,String as,String typeName,String refName, String refTableAddString){
        BelongsToMapping belongsToMapping = new BelongsToMapping();
        belongsToMapping.foreignKey = foreignKey;
        belongsToMapping.targetKey = targetKey;
        belongsToMapping.refTableAddString = refTableAddString;
        belongsToMapping.as = as;
        belongsToMapping.typeName = typeName;
        belongsToMapping.refName = refName;
        return belongsToMapping;
    }


}
